<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('已竣工项目')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>项目编号：</label>
                                <input type="text" name="orderNo" autoComplete="off"/>
                            </li>
                            <li>
                                <label>单位名称：</label>
                                <input type="text" name="customerName" autoComplete="off"/>
                            </li>
                            <li>
                                <label>名称：</label>
                                <input type="text" name="name" autoComplete="off"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('gcgl:yyproject:edit')}]];
        var removeFlag = [[${@permission.hasPermi('gcgl:yyproject:remove')}]];
        var datas = [[${@dict.getType('sj_contract_status')}]];
        
        var prefix = ctx + "yy/project";
        
        function editHome(projectId) {
            $.modal.openTab('项目资料',"/yy/project/editHome/"+projectId);
        }
		
        function detail(projectId) {
            $.modal.openTab('项目详情',"/yy/project/detail/"+projectId);
        }
        
        $(function() {
            var options = {
                url: prefix + "/listJs",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "项目立项",
                sortName: "id desc",
                sortOrder: "",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'orderNo',
                    title: '项目编号'
                },
                {
                    field: 'customerName',
                    title: '单位名称'
                },
                {
                    field: 'name',
                    title: '项目名称'
                },
                {
                    field: 'descs',
                    title: '项目描述'
                },
                {
                    field: 'glf',
                    title: '项目管理费',
                    visible: false
                },
                {
                    field: 'owner',
                    title: '申请人'
                },
                {
                    field: 'authorityName',
                    title: '项目所属'
                },
                {
                    field: 'spr',
                    title: '工程经理审批',
                    visible: false
                },
		        {
                    field: 'zjlsh',
                    title: '总经理审批',
                    visible: false
                },
                {
		            field: 'status',
		            title: '状态',
		            align: "left",
		            formatter: function(value, item, index) {
		            	return $.table.selectDictLabel(datas, item.status);
		            }
		        },
		        {
                    field: 'spyj',
                    title: '审批意见',
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="editHome(\'' + row.id + '\')"><i class="fa fa-plus"></i>项目详情</a> ');
//                         if(row.status==3){
//                         	actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="jg(\'' + row.id + '\')"><i class="fa fa-check"></i>项目竣工</a> ');
//                         }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        
        function jg(id){
        	$.modal.confirm("确认要项目竣工吗?", function() {
	    		$.ajax({
    				url: "/yy/project/proClose",
    				type: "post",
    				data: { "id": id },
    				dataType: 'json',
    				success: function(data) {
    					$.table.refresh();
    				},
    				error: function(xhr, type, errorThrown) {
    					//异常处理；
    					$.modal.alert("请稍后再试！");
    					$.table.refresh();
    				}
    			});
	    	});
        }
    </script>
</body>
</html>